<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="css/eui.css">

</head>
<body>
<div id="app">
    <input type="text" v-model="name">
    <input type="text" v-model="salary">
    <input type="text" v-model="job">
    <input type="button" value="添加" @click="f()">
    <template>
        <el-table
                :data="arr"
                style="width: 100%">
            <el-table-column
                    type="index"
                    width="50" label="编号">
            </el-table-column>
            <el-table-column prop="name" label="姓名" width="180"></el-table-column>
            <el-table-column prop="salary" label="工资" width="180"></el-table-column>
            <el-table-column prop="job" label="工作"width="180"></el-table-column>
            <el-table-column label="操作" width="180">
                <template slot-scope="scope">
         <!--scope代表每行对应的数据里面的index属性代表下标，里面的row代表每行对应的数组中对象-->
                    <el-popconfirm @confirm="handleDelete(scope.$index, scope.row)"
                            title="这是一段内容确定删除吗？"
                    >
                        <el-button
                                size="mini"
                                type="danger"
                                slot="reference">删除</el-button>
                    </el-popconfirm>
                </template>
            </el-table-column>
        </el-table>
    </template>
</div>
</body>
<!-- import Vue before Element -->
<script src="js/vue.js"></script>
<!-- import JavaScript -->
<script src="js/eui.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function() {
            return {
              arr:[{name:"网二",salary:5000,job:"老师"},
              ],
                name:"",salary:"",job:"",
            }
        },methods:{
            f(){
                 if(v.name.trim()==""){
                     v.$message.error("输入有误");
                     return;
                 }
                v.arr.push({name:v.name,salary:v.salary,job:v.job});
            },handleDelete(index){
                v.arr.splice(index)
            }
        }
    })
</script>
</html>